package br.eng.megaprojetos.model;

import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import br.com.vexillum.model.annotations.Validate;
import br.eng.megaprojetos.model.enums.CivilState;

@SuppressWarnings("serial")
@Entity
@Table(name="functionary")
public class Functionary extends Person {
	
	public Functionary() {
		this.active = true;
	}

	@Validate(notNull=true)
	@Column(name="civil_state", unique=false, updatable=true)
	@Enumerated(EnumType.ORDINAL)
	private CivilState civilState;
	
	@Column(name = "pis", nullable = false, unique = true, updatable = true)
	private Long pis;
	
	@Column(name = "salary", nullable = false, unique = false, updatable = true)
	private Double salary;
	
	@ManyToOne(fetch=FetchType.LAZY)
	@JoinColumn(name="id_post", nullable=false, updatable=true)
	private Post post;
	
	@Column(name = "date_admission", nullable = false, unique = false, updatable = false)
	private Date dateAdmission;

	@Column(name = "date_dismissal", nullable = false, unique = false, updatable = false)
	private Date dateDismissal;
	
	@Column(name = "obs", nullable = true, unique = false, updatable = true)
	private Date obs;
	
	public CivilState getCivilState() {
		return civilState;
	}

	public void setCivilState(CivilState civilState) {
		this.civilState = civilState;
	}
	
	public void setCivilState(String civilState) {
		this.civilState = CivilState.valueOf(civilState);
	}
	
	public void setCivilState(Integer id) {
		this.civilState = CivilState.getCivilStateById(id);
	}

	public Long getPis() {
		return pis;
	}

	public void setPis(Long pis) {
		this.pis = pis;
	}

	public Double getSalary() {
		return salary;
	}

	public void setSalary(Double salary) {
		this.salary = salary;
	}

	public Post getPost() {
		return post;
	}

	public void setPost(Post post) {
		this.post = post;
	}

	public Date getDateAdmission() {
		return dateAdmission;
	}

	public void setDateAdmission(Date dateAdmission) {
		this.dateAdmission = dateAdmission;
	}

	public Date getDateDismissal() {
		return dateDismissal;
	}

	public void setDateDismissal(Date dateDismissal) {
		this.dateDismissal = dateDismissal;
	}

	public Date getObs() {
		return obs;
	}

	public void setObs(Date obs) {
		this.obs = obs;
	}
	
}
